package top.greatxiaozou.BuilderPattern;

import java.util.ArrayList;
import java.util.List;

public class Meal {
    List<Item> items = new ArrayList<Item>();

    public void addItem(Item item){
        items.add(item);
    }

    //获取该meal的总价
    public double getCost(){
        double cost = 0;
        for (Item item : items) {
            cost+=item.price();
        }
        return cost;
    }
    //获取该meal的所有item项
    public void showItem(){
        for (Item item : items) {
            System.out.println("Item:"+item.name());
            System.out.println("packing:"+item.packing().pack());
            System.out.println("price:"+item.price());
        }
    }
}
